package com.southwind.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO<T> {

    private Integer code;
    private String msg;
    private T data;

    public static <T> ResultVO<T> successWithData(T data) {
        return new ResultVO<T>(0, "成功", data);
    }
    public static ResultVO successWithoutData() {
        return new ResultVO(0, "成功", null);
    }

    public static ResultVO failWithMsg(String msg) {
        return new ResultVO(0, msg, null);
    }

    public static ResultVO failWithoutMsg() {
        return new ResultVO(0, "失败", null);
    }

    public static ResultVO auto(boolean b) {
        ResultVO success = new ResultVO(0, "成功", null);
        ResultVO fail = new ResultVO(0, "失败", null);
        return b ? success : fail;
    }
}
